package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.AccountDao;
import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Override
    public Boolean addAccount(Account account) {
        return accountDao.addAccount(account);
    }

    @Override
    public Boolean updateAccount(Account account) {
        return accountDao.updateAccount(account);
    }

    @Override
    public Boolean deleteAccount(String id) {
        return accountDao.deleteAccount(id);
    }

    @Override
    public Account findAccountById(String id) {
        return accountDao.findAccountById(id);
    }

    @Override
    public PageInfo<Account> findAccount(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        Page<Account> account = accountDao.findAccount();
        return new PageInfo<>(account);
    }


}
